import { ASTNode, ConstNode, ExpNode } from './AST';
import expr from './expr';
//@ts-ignore
//console.log(expr.parse("@sdasdasd + \"sda\""));
let exp = "@abc + \"sda\" - 123 * 5 + \"123\" + (4 + 5)"
exp = "1+5￥"
//@ts-ignore
let root = expr.parse(exp)
function dfs(root:ASTNode,depth = 0){
    if(root instanceof ConstNode){
        console.log(">".repeat(depth),root.type,"[",root.value.value,"]")
    }else{
        console.log(">".repeat(depth),root.type)   
    }
    
    if(root instanceof ExpNode && root.children){
        for(let i=0;i<root.children.length;i++){
            dfs(root.children[i],depth+1)
        }
    }
}
dfs(root)
//expr.parser.parse("1+2")